package com.gufe.controller.user.mp.excellentperson;

import com.gufe.dto.excellentperson.ExcellentPersonnelDTO;
import com.gufe.result.Result;
import com.gufe.service.user.mp.excellentperson.ExcellentPersonnelService;
import com.gufe.vo.excellentperson.ExcellentPersonnelVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/excellentPersonnel")
public class ExcellentPersonnelController {

    @Autowired
    private ExcellentPersonnelService personnelService;

    @PostMapping
    public Result<ExcellentPersonnelVO> createPersonnel(@RequestBody ExcellentPersonnelDTO personnelDTO) {
        return personnelService.createPersonnel(personnelDTO);
    }

    @GetMapping("/{id}")
    public Result<ExcellentPersonnelVO> getPersonnelById(@PathVariable Integer id) {
        return personnelService.getPersonnelById(id);
    }

    @PutMapping("/{id}")
    public Result<ExcellentPersonnelVO> updatePersonnel(@PathVariable Integer id, @RequestBody ExcellentPersonnelDTO personnelDTO) {
        return personnelService.updatePersonnel(id, personnelDTO);
    }

    @DeleteMapping("/{id}")
    public Result<Void> deletePersonnel(@PathVariable Integer id) {
        return personnelService.deletePersonnel(id);
    }

    @GetMapping("/list")
    public Result<List<ExcellentPersonnelVO>> getAllPersonnel() {
        return personnelService.getAllPersonnel();
    }
}